import win32con
import win32clipboard as w

class GetText():
    '''保存到剪切板'''

    @classmethod
    def getText(cls):
        '''获取剪切板的内容'''

        w.OpenClipboard()
        d = w.GetClipboardData(win32con.CF_UNICODETEXT)
        w.CloseClipboard()

        return d

    @classmethod
    def setText(cls, aString):
        '''将aString 放在剪切板里'''
        w.OpenClipboard()
        w.EmptyClipboard()
        w.SetClipboardData(win32con.CF_UNICODETEXT, aString)
        w.CloseClipboard()

if '__main__' == __name__:
    GetText.setText('xxxxxxx')
    d = GetText.getText()

    print(d)